﻿using System;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Microsoft.Practices.Prism.Logging;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.ServiceLocation;

namespace Tanmia.Basis.Prism
{
    public class WindsorModuleInitializer : ModuleInitializer
    {
        protected IWindsorContainer Continer { get; private set; }

        public WindsorModuleInitializer(IWindsorContainer container, IServiceLocator serviceLocator, ILoggerFacade loggerFacade)
            : base(serviceLocator, loggerFacade)
        {
            this.Continer = container;
        }

        protected override IModule CreateModule(ModuleInfo moduleInfo)
        {
            Continer.Register(Component.For(Type.GetType(moduleInfo.ModuleType)));
            return base.CreateModule(moduleInfo);
        }
    }
}
